package Bird;
abstract class Bird{//定义一个抽象类Bird
    //定义4个抽象方法
    abstract void flying();
    abstract void nesting();
    abstract void eating();
    abstract void singing();
}

class Eagle extends Bird{//子类Eagle
    void flying(){
        System.out.println("Eagle is flying");
    }
    void nesting(){
        System.out.println("Eagle is nesting");
    }
    void eating(){
        System.out.println("Eagle is eating");
    }
    void singing(){
        System.out.println("Eagle is singing");
    }
}

class Dove extends Bird{//子类Dove
    void flying(){
        System.out.println("Dove is flying");
    }
    void nesting(){
        System.out.println("Dove is nesting");
    }
    void eating(){
        System.out.println("Dove is eating");
    }
    void singing(){
        System.out.println("Dove is singing");
    }
}

class Sparrow extends Bird{//子类Sparrow
    void flying(){
        System.out.println("Sparrow is flying");
    }
    void nesting(){
        System.out.println("Sparrow is nesting");
    }
    void eating(){
        System.out.println("Sparrow is eating");
    }
    void singing(){
        System.out.println("Sparrow is singing");
    }
}

public class test {
    public static void main(String[] args) {
        //分别使用这三个子类创建对象实体，
        Eagle eagle = new Eagle();
        Dove dove = new Dove();
        Sparrow sparrow = new Sparrow();

        //把eagle的引用方法放到e的声明中，使e成为eagle的上转型对象
        Bird e = eagle;
        //调用Bird类中的方法
        e.flying();
        e.nesting();
        e.eating();
        e.singing();
        System.out.println();

        //把dove的引用方法放到d的声明中，使d成为dove的上转型对象
        Bird d = dove;
        //调用Bird类中的方法
        d.flying();
        d.nesting();
        d.eating();
        d.singing();
        System.out.println();

        //把sparrow的引用方法放到s的声明中，使s成为sparrow的上转型对象
        Bird s = sparrow;
        //调用Bird类中的方法
        s.flying();
        s.nesting();
        s.eating();
        s.singing();
        System.out.println();
    }
}
